cmake_minimum_required(VERSION 3.20)
set(CMAKE_CXX_STANDARD 14)

# 项目名称
project(Integration LANGUAGES CXX)

# 获取源文件
file(GLOB SOURCES 
    ${CMAKE_CURRENT_SOURCE_DIR}/IntegrationFormula/*.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/ShapeFunction/*.cpp)

# 添加动态库
add_library(${PROJECT_NAME} SHARED ${SOURCES})

# 目标添加链接库
target_link_libraries(${PROJECT_NAME} PRIVATE DataStructure Algebra)

# 目标添加编译选项
target_compile_definitions(${PROJECT_NAME} PRIVATE EXPORTING_Integration)

# 安装头文件
install(DIRECTORY ${PROJECT_SOURCE_DIR}/Common/             DESTINATION include/SGFem/Integration/Common)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/IntegrationFormula/ DESTINATION include/SGFem/Integration/IntegrationFormula
    FILES_MATCHING PATTERN "*.h" PATTERN "UnitTest" EXCLUDE)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/ShapeFunction/      DESTINATION include/SGFem/Integration/ShapeFunction
    FILES_MATCHING PATTERN "*.h" PATTERN "UnitTest" EXCLUDE)

# 安装目标
install(TARGETS ${PROJECT_NAME}
    ARCHIVE DESTINATION lib
    RUNTIME DESTINATION bin)

# 添加单元测试子项目
if(SG_BUILD_UNIT_TEST)
    add_subdirectory(UnitTest)
endif()